package bstsetcode.stanforduniversity18;

/**
 * @author noob
 * @version 1.0
 * @date 2021/3/15 17:13
 */
public class _04_Push {


    public static void main(String[] args) {

        LinkedList<Integer> list = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            if (i % 2 == 0) {
                list.addFirst(i);
                System.out.println(list);
            } else {
                list.addLast(i);
                System.out.println(list);
            }
        }

        System.out.println("----------------------------");

        for (int i = 0; i < 10; i++) {
            if(i % 2 ==0){
                list.removeFirst();
                System.out.println(list);
            }else{
                list.removeLast();
                System.out.println(list);
            }

        }


        System.out.println(list);
    }
}
